package com.example.aslongastoday.db.dao;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;

import com.example.aslongastoday.domain.BackLog;
import com.example.aslongastoday.domain.BackLogGroup;
import com.example.aslongastoday.util.TimeUtil;

import junit.framework.TestCase;

public class BackLogDaoTest extends TestCase {
    BackLogGroupDao backLogGroupDao;
    BackLogDao dao;


    public void init(){
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        backLogGroupDao = BackLogGroupDao.getInstance(appContext);
        dao = BackLogDao.getInstance(appContext);
    }

    public void testDelete() {
        init();
        BackLogGroup query = backLogGroupDao.query(6);
        dao.recycle(6,0);
        BackLogGroup query1 = backLogGroupDao.query(6);

        System.out.println(query1);
    }

    public void testQuery(){
        init();
        BackLog query = dao.query(6, 0);

        System.out.println(query);
    }

    public void testInsert(){
        init();
        BackLog backLog = new BackLog("这是测试插入的话题", "这是测试插入的内容", TimeUtil.getNowTime(), 1);
        dao.insert(6,backLog);

        BackLogGroup query = backLogGroupDao.query(6);
        System.out.println(query);
    }

    public void testUpdate(){
        init();
        BackLog backLog = new BackLog(null,null, TimeUtil.getNowTime(), 1);
        dao.update(6,2,backLog);

        BackLogGroup query = backLogGroupDao.query(6);
        System.out.println(query);
    }
}